package com.bw.interceptor;

import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author bobo棒
 * @date 2025年02月26日 11:36
 */

public class LoginInterceptor implements HandlerInterceptor {

    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        //判断用户是否登录
        Object user = request.getSession().getAttribute("user");
        //如果用户登录则不拦截
        if(user!=null){
            return true;
        }
       //如果没有登录,则拦截
      //  response.sendRedirect("/auth/tologin.do");

        return true;
    }
}
